#!/usr/bin/env bash
set -e

JSDUCK_MWVERSION=master
if [[ "$1" == "--version" && "$2" != "" ]]
then
	JSDUCK_MWVERSION="$2"
elif [[ "$*" != "" ]]
then
	FILENAME=$(basename $0)
	echo "Usage: $FILENAME [--version <mediawiki version>]"
	echo
	exit 1
fi

MWCORE_DIR=$(cd $(dirname $0)/..; pwd)

jsduck \
--config=$MWCORE_DIR/maintenance/jsduck/config.json \
--footer="Documentation for branch ($JSDUCK_MWVERSION) on {DATE} by {JSDUCK} {VERSION}." \
--processes 0

echo 'JSDuck execution finished.'

ln -s ../../resources $MWCORE_DIR/docs/js/modules
